package com.sphd.restaurantsystem.presenter;


import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;

import com.android.volley.VolleyError;
import com.sphd.restaurantsystem.info.MoneyRecordInfo;
import com.sphd.restaurantsystem.model.MoneyRecordModelImpl;
import com.sphd.restaurantsystem.view.MoneyRecordView;

import java.util.List;

/**
* Created by Hu on 2016/12/30
*/

public class MoneyRecordPresenterImpl implements MoneyRecordPresenter {
        MoneyRecordModelImpl moneyRecordModel;
    MoneyRecordView moneyRecordView;
    AlertDialog alertDialog;
    DialogInterface dialog;
    public MoneyRecordPresenterImpl(MoneyRecordView moneyRecordView) {
        this.moneyRecordView = moneyRecordView;
        moneyRecordModel=new MoneyRecordModelImpl();
    }

    @Override
    public void addData(String url) {
        moneyRecordModel.sendUrl(url,this);
    }

    @Override
    public void sendError(VolleyError error) {
        moneyRecordView.dissLoading();
    }

    @Override
    public void getList(List<MoneyRecordInfo> moneyRecordInfoList) {
        moneyRecordView.getList(moneyRecordInfoList);
    }

    @Override
    public void sumAccount(double sum_account) {
        moneyRecordView.sumAccount(sum_account);
    }

    @Override
    public void setDialog(String url, AlertDialog alertDialog) {
        this.alertDialog=alertDialog;
        moneyRecordView.showLoading();
        moneyRecordModel.setResUrl(url,this);

    }

    @Override
    public void recRes(int res) {
        moneyRecordView.recRes(res,alertDialog);
        moneyRecordView.dissLoading();
    }

    @Override
    public void setOpenCloseDialog(String url, DialogInterface dialog) {
        this.dialog=dialog;
        moneyRecordModel.setOpenCloseResUrl(url,this);
    }

    @Override
    public void recOpenCloseRes(int res) {
        moneyRecordView.recOpenCloseRes(res,dialog);
        moneyRecordView.dissLoading();
    }
}